<template>
	<view class='page_cont'>
		<view class='hide_wrap'>
			<view class='text'>隐藏简历</view>
			<switch :checked="hide" @change="switch_change" style="transform:scale(0.625)" color="#5B90FF" v-if="checked==1" />
			<switch :checked="show" @change="switch_change" style="transform:scale(0.625)" color="#5B90FF" v-else />
		</view>
		<view class='hide_com'>
			<view class='title_wrap' @click="nav_com()">
				<view class='title'>已屏蔽企业</view>
				<image class='icon' src="/static/icon47.png"></image>
			</view>
			<scroll-view class='list' scroll-y="true" scroll-with-animation="">
				<view class='item' v-for="(item,index) in list" :key="index">
					<view class='com'>{{item.businessName}}</view>
					<image class='icon' src="/static/icon9.png" @click="del_corpor(index)"></image>
				</view>
			</scroll-view>
		</view>
		<view class="mask" @touchmove.stop.prevent="moveHandle" v-show="show_pop">
			<view class='pop'>
				<view class='title'>隐藏简历须知</view>
				<view class='point'>隐藏简历后，您将不会被推荐给校长，除非您主动简历联系，否则校长无法查看您的简历</view>
				<view class='btn_wrap'>
					<view class='btn' @click="cancel_pop()">取消</view>
					<view class='btn' @click="confirm_del()">确定</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import config from "../../api/config.js"
	import util from "../../utils/util.js"
	export default{
		data(){
			return{
				id: '',
				type: 1,
				checked: '',
				userinfo: '',
				list: [],
				ids: [],
				hide: false,
				show: true,
				add: false,
				show_pop: false
			}
		},
		onLoad(options) {
			var that=this;
			that.type=options.type;
			that.checked=options.checked;
			that.id=options.id;
			that.get_corpor_list();
		},
		onShow() {
			if(this.add){
				this.get_corpor_list();
			}
		},
		methods:{
			// 简历状态
			switch_change(e){
				var value=e.detail.value;
				if(value){
					this.hide=true
					this.show_pop=true
				}else{
					this.checked=1
					this.edit_user_resume(1)
				}
			},
			// 取消
			cancel_pop(){
				this.hide=false
				this.show_pop=false;
			},
			// 确定隐藏
			confirm_del(){
				this.show_pop=false;
				this.edit_user_resume(0)
			},
			// 屏蔽公司
			nav_com(){
				uni.navigateTo({
					url: '../hideCompany/hideCompany?len='+this.list.length+'&ids='+this.ids.join(",")
				})
			},
			// 删除
			del_corpor(index){
				this.cancel_corpor(this.list[index].id,index)
			},
			// 修改简历是否公开
			edit_user_resume(checked){
				var params={
					"isPublic": checked,
					"id": this.id
				}
				config.edit_user_resume(params).then(res=>{
					
				})
			},
			// 屏蔽公司列表
			get_corpor_list(){
				config.get_corpor_list().then(res=>{
					var list=res.data.data,arr=[];
					this.list=list
					list.forEach((item)=>{
						arr.push(item.businessId)
					})
					this.ids=arr
				})
			},
			// 取消屏蔽公司
			cancel_corpor(id,index){
				config.cancel_corpor({"id":id}).then(res=>{
					this.list.splice(index,1)
					this.ids.splice(index,1)
				})
			}
		}
	}
</script>

<style lang="scss">
	.page_cont{
		padding: 16rpx 32rpx;
		.hide_wrap{
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-bottom: 52rpx;
			.text{
				flex: 1;
				height: 42rpx;
				font-size: 30rpx;
				font-weight: 600;
				line-height: 42rpx;
				color: #3F4A58;
			}
		}
		.hide_com{
			width: 100%;
			.title_wrap{
				display: flex;
				flex-direction: row;
				align-items: center;
				margin-bottom: 8rpx;
				.title{
					flex: 1;
					height: 42rpx;
					font-size: 30rpx;
					font-weight: 600;
					line-height: 42rpx;
					color: #3F4A58;
				}
				.icon{
					width: 50rpx;
					height: 50rpx;
				}
			}
			.list{
				height: 82vh;
				.item{
					display: flex;
					flex-direction: row;
					align-items: center;
					padding: 32rpx 0;
					border-bottom: 2rpx solid #F6F7F9;
					.com{
						flex: 1;
						height: 40rpx;
						font-size: 28rpx;
						font-weight: 600;
						line-height: 40rpx;
						color: #3F4A58;
					}
					.icon{
						width: 32rpx;
						height: 32rpx;
					}
				}
			}
		}
		.pop {
			width: 560rpx;
			/* #ifdef MP-WEIXIN||APP-PLUS */
			margin: 360rpx auto 0 auto;
			/* #endif */
			/* #ifdef H5 */
			margin: 500rpx auto 0 auto;
			/* #endif */
			background: #fff;
			border-radius: 16rpx;
			padding: 52rpx 48rpx;
			.title{
				text-align: center;
				height: 50rpx;
				font-size: 36rpx;
				font-weight: 600;
				line-height: 50rpx;
				color: #3F4A58;
			}
			.point {
				text-align: left;
				font-size: 30rpx;
				font-weight: 600;
				line-height: 40rpx;
				color: #3F4A58;
				margin: 32rpx 0;
			}
			.btn_wrap {
				width: 100%;
				display: flex;
				flex-direction: row;
				.btn {
					flex: 1;
					height: 88rpx;
					text-align: center;
					line-height: 88rpx;
					font-size: 30rpx;
					font-weight: 400;
					border-radius: 16rpx;
		
					&:first-child {
						background: rgba(146, 155, 167, 0.15);
						color: #798594;
						margin-right: 38rpx;
					}
		
					&:last-child {
						background: #5B90FF;
						color: #fff;
					}
				}
			}
		}
	}
</style>
